package main;

import java.awt.Rectangle;

import math.Vector2D;

public class Screen
{
	//position of top-left hand corner of the viewing window
	private Vector2D pos;
	
	private int width, height;
	
	private int endX, endY;
	
	public Screen( int endX, int endY )
	{
		pos = new Vector2D();
		
		width = 1024;
		height = 640;
		
		this.endX = endX;
		this.endY = endY;
	}
	
	
	public Vector2D getDimensions()
	{
		return new Vector2D( width, height );
	}
	
	public void move( Vector2D v )
	{
		pos.add( v );
		
		truncate();
	}
	
	public Vector2D getPosition()
	{
		return pos;
	}
	
	public void setPosition( Vector2D v )
	{
		pos = v;
		
		truncate();
	}
	
	public void setCenter( Vector2D v )
	{
		pos = v.subtract( new Vector2D( width / 2, height / 2 ) );
		
		truncate();
	}
	
	public void truncate()
	{
		if( pos.getX() < 0 )
		{
			pos.setX( 0 );
		}
		else if( pos.getX() + width > endX )
		{
			pos.setX( endX - width );
		}
		
		if( pos.getY() < 0 )
		{
			pos.setY( 0 );
		}
		else if( pos.getY() + height > endY )
		{
			pos.setY( endY - height );
		}
	}
}
